<?php
	session_start();	
?>

<!DOCTYPE html PUBLIC "-//W3C//DT D XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html lang="en-US" xmlns="http://www.w3.org/1999/xhtml" dir="ltr">
<head>

	<title>PizzaRio ~ voor al uw zelfgemaakte pizza's!</title>
	
	<meta http-equiv="Content-type" content="text/html; charset=utf-8" />
	<link rel="stylesheet" href="css/style.css" type="text/css" media="all" />
	<link rel="stylesheet" href="css/jquery.jcarousel.css" type="text/css" media="all" />
	<!--[if IE 6]>
		<link rel="stylesheet" href="css/ie6.css" type="text/css" media="all" />
	<![endif]-->
	<link rel="icon" href="css/images/favicon.ico" type="image/x-icon" />
	<script type="text/javascript" src="js/jquery-1.4.2.min.js"></script>
	<script type="text/javascript" src="js/jquery.jcarousel.pack.js"></script>
	<script type="text/javascript" src="js/func.js"></script>
	
	<script type="text/javascript" src="js/Scrolling.js"></script>
    	
</head>

<body>

<!-- Topvakje links bovenin -->
<div class="shell">
	<div class="border">
		<div id="header">
			<img src="css/images/logo.gif" alt="PizzaRio ~ voor al uw zelfgemaakte pizza's!" />
			<div class="socials right">
				<ul>
				    <li><a href="#" class="rss">RSS</a></li>
				    <li><a href="http://www.facebook.com" class="fb">Facebook</a></li>
				    <li class="last"><a href="http://www.twitter.com" class="twit">Twitter</a></li>
				</ul>
				<div>
					 <ul>
					 		 <li>
								<form name="form1" method="post" action="login/checklogin.php">
								<input type="hidden" name="submitted" value="true" />
							 		<input name="myusername" type="text" id="myusername" value="Gebruikersnaam">
							 </li>
							 <li>
							 <input name="mypassword" type="text" id="mypassword" value="wachtwoord">
							 </li>
					 </ul>
					 <ul>
						<li><input type="submit" name="Submit" value="Login" width="200px">
						</form></li>
					 </ul>
					 
					 <ul>
						<?php
							if(isset($_SESSION['submitted'])){
								if(($_SESSION['submitted']) > 1){
									echo "Al ingelogd. <br />";
								}
							}	
							if(isset($_SESSION['myusername'])){
								Echo "<li>Welkom ". $_SESSION['myusername'] . "</li>";
								Echo "<li><a href=\"gegevens.php\">gegevens</a></li>";
								Echo "<li><a href=\"Logout.php\">logout</a></li>";		
							}
							if(!isset($_SESSION['myusername'])){
								Echo "<li>Welkom Gast</li>";
								Echo "<li>Registreer <a href=\"registreer.php\">Hier</a></li>";		
							}
							if(isset($_SESSION['members'])){
								if($_SESSION['members']['niveau_id'] >= 2){
									echo "<li><a href=\"backend/back_end.php\">Backend</a></li>";
								}
							}						
						?>
						
				<ul>
			 </div>
			</div>

			<div class="cl">&nbsp;</div>
		</div>
		
		<div id="navigation">
			<ul>
			    <li><a href="index.php" class="active">Home</a></li>
			    
			     <li><a href="menu.php">Menu</a></li>
			     <li><a href="samenstellen.php">Pizza Maken</a></li>
			    <li><a href="mijnpizzas.php">Mijn Pizza's</a></li>
			   
			</ul>
			<div class="cl">&nbsp;</div>
		</div>
		
		<div class="slider">
			<div class="slider-nav">
				<a href="index.html" class="left notext">1</a>
				<a href="#" class="left notext">2</a>
				<a href="#" class="left notext">3</a>
				<div class="cl">(iets)?</div>
			</div>
			<ul>
			    <li>
			    	<div class="item">
						<div class="text">
						</div>
			    		<img src="css/images/slider01.png" alt="Welkom bij PizzaRio!" />
			    	</div>
			    </li>
			    <li>
			    	<div class="item">
						<div class="text">
						</div>
			    		<img src="css/images/slider02.png" alt="" />
			    	</div>
			    </li>
			    <li>
			    	<div class="item">
						<div class="text">
						</div>
			    		<img src="css/images/Slider03.png" alt="Maak je eigen pizza!" />
			    	</div>
			    </li>
			</ul>
		</div>
		
		<div id="main">
			<div id="content" class="left">
				<div class="highlight"><br/><br/><br/><br/><br/><br/><br/><br/>
				<?php
				
				


$link = mysql_connect('localhost','',''); 
if (!$link) { 
	die('Could not connect to MySQL: ' . mysql_error()); 
} 
mysql_select_db("pizzacat") or die(mysql_error());

$klant_id = $_SESSION['members']['id'];
$name = $_POST['name'];
$_SESSION['pizza_name'] = $name;
$size = $_POST['size'];
$crust = $_POST['crust'];

mysql_query("INSERT pizza (name, size, crust, id_customer, public) VALUES('$name', '$size', '$crust', '$klant_id', '0')") or die(mysql_error());

$meat_1 = $_POST['meat_1'];
$fruit_1 = $_POST['fruit_1'];
$cheese_1 = $_POST['cheese_1'];

$meat_2 = $_POST['meat_2'];
$fruit_2 = $_POST['fruit_2'];
$cheese_2 = $_POST['cheese_2'];

$meat_3 = $_POST['meat_3'];
$fruit_3 = $_POST['fruit_3'];
$cheese_3 = $_POST['cheese_3'];

$meat_4 = $_POST['meat_4'];
$fruit_4 = $_POST['fruit_4'];
$cheese_4 = $_POST['cheese_4'];


$res = mysql_query("SELECT MAX(id) AS last FROM pizza GROUP BY id DESC") or die(mysql_error());
$row = mysql_fetch_assoc($res);
$pizza_id = $row['last'];
$_SESSION['pizza_id'] = $row['last'];


if ( $meat_1 == '0' ) {
} else { 
	mysql_query("INSERT meat_pizza (id_pizza, id_meat) VALUES('$pizza_id', '$meat_1')") or die(mysql_error());
}
if ( $meat_2 == '0' ) {
} else { 
	mysql_query("INSERT meat_pizza (id_pizza, id_meat) VALUES('$pizza_id', '$meat_2')") or die(mysql_error());
}
if ( $meat_3 == '0' ) {
} else { 
	mysql_query("INSERT meat_pizza (id_pizza, id_meat) VALUES('$pizza_id', '$meat_3')") or die(mysql_error());
}
if ( $meat_4 == '0' ) {
} else { 
	mysql_query("INSERT meat_pizza (id_pizza, id_meat) VALUES('$pizza_id', '$meat_4')") or die(mysql_error());
}


if ( $fruit_1 == '0' ) {
} else { 
	mysql_query("INSERT fruit_pizza (id_pizza, id_fruit) VALUES('$pizza_id', '$fruit_1')") or die(mysql_error());
}
if ( $fruit_2 == '0' ) {
} else { 
	mysql_query("INSERT fruit_pizza (id_pizza, id_fruit) VALUES('$pizza_id', '$fruit_2')") or die(mysql_error());
}
if ( $fruit_3 == '0' ) {
} else { 
	mysql_query("INSERT fruit_pizza (id_pizza, id_fruit) VALUES('$pizza_id', '$fruit_3')") or die(mysql_error());
}
if ( $fruit_4 == '0' ) {
} else { 
	mysql_query("INSERT fruit_pizza (id_pizza, id_fruit) VALUES('$pizza_id', '$fruit_4')") or die(mysql_error());
}


if ( $cheese_1 == '0' ) {
} else { 
	mysql_query("INSERT cheese_pizza (id_pizza, id_cheese) VALUES('$pizza_id', '$cheese_1')") or die(mysql_error());
}
if ( $cheese_2 == '0' ) {
} else { 
	mysql_query("INSERT cheese_pizza (id_pizza, id_cheese) VALUES('$pizza_id', '$cheese_2')") or die(mysql_error());
}
if ( $cheese_3 == '0' ) {
} else { 
	mysql_query("INSERT cheese_pizza (id_pizza, id_cheese) VALUES('$pizza_id', '$cheese_3')") or die(mysql_error());
}
if ( $cheese_4 == '0' ) {
} else { 
	mysql_query("INSERT cheese_pizza (id_pizza, id_cheese) VALUES('$pizza_id', '$cheese_4')") or die(mysql_error());
}


$meat_res = mysql_query("SELECT COUNT(meat.price) AS meatprice FROM meat_pizza, meat WHERE meat_pizza.id_meat = meat.id AND meat_pizza.id_pizza = $pizza_id") or die(mysql_error());
$meat = mysql_result($meat_res, 0);

$fruit_res = mysql_query("SELECT COUNT(fruit.price) AS fruitprice FROM fruit_pizza, fruit WHERE fruit_pizza.id_fruit = fruit.id AND fruit_pizza.id_pizza = $pizza_id") or die(mysql_error());
$fruit = mysql_result($fruit_res, 0);

$cheese_res = mysql_query("SELECT COUNT(cheese.price) AS cheeseprice FROM cheese_pizza, cheese WHERE cheese_pizza.id_cheese = cheese.id AND cheese_pizza.id_pizza = $pizza_id") or die(mysql_error());
$cheese = mysql_result($cheese_res, 0);

$size_res = mysql_query("SELECT size.price FROM pizza, size WHERE pizza.size = size.id AND pizza.id = $pizza_id") or die(mysql_error());
$size = mysql_result($size_res, 0);

$crust_res = mysql_query("SELECT crust.price FROM pizza, crust WHERE pizza.crust = crust.id AND pizza.id = $pizza_id") or die(mysql_error());
$crust = mysql_result($crust_res, 0);

$total = $meat + $fruit + $cheese + $size + $crust;

echo "You have succesfully created a pizza $name. <br/> ";
echo "This pizza costs $total euro. <br/>";
$comma = ', ';


$size_res = mysql_query("SELECT name FROM size WHERE id = $size") or die(mysql_error());
$size = mysql_result($size_res, 0);


$crust_res = mysql_query("SELECT name FROM crust WHERE id = $crust") or die(mysql_error());
$crust = mysql_result($crust_res, 0);
$crust = "$comma $crust";

if ( $meat_1 == '0' ) {
$meat_1 = '';
} else { 
$meat_1res = mysql_query("SELECT name FROM meat WHERE id = $meat_1") or die(mysql_error());
$meat_1 = mysql_result($meat_1res, 0);
$meat_1 = "$comma $meat_1";
}
if ( $meat_2 == '0' ) {
$meat_2 = '';
} else { 
$meat_2res = mysql_query("SELECT name FROM meat WHERE id = $meat_2") or die(mysql_error());
$meat_2 = mysql_result($meat_2res, 0);
$meat_2 = "$comma $meat_2";
}
if ( $meat_3 == '0' ) {
$meat_3 = '';
} else { 
$meat_3res = mysql_query("SELECT name FROM meat WHERE id = $meat_3") or die(mysql_error());
$meat_3 = mysql_result($meat_3res, 0);
$meat_3 = "$comma $meat_3";
}
if ( $meat_4 == '0' ) {
$meat_4 = '';
} else { 
$meat_4res = mysql_query("SELECT name FROM meat WHERE id = $meat_4") or die(mysql_error());
$meat_4 = mysql_result($meat_4res, 0);
$meat_4 = "$comma $meat_4";
}


if ( $fruit_1 == '0' ) {
$fruit_1 = '';
} else { 
$fruit_1res = mysql_query("SELECT name FROM fruit WHERE id = $fruit_1") or die(mysql_error());
$fruit_1 = mysql_result($fruit_1res, 0);
$fruit_1 = "$comma $fruit_1";
}
if ( $fruit_2 == '0' ) {
$fruit_2 = '';
} else { 
$fruit_2res = mysql_query("SELECT name FROM fruit WHERE id = $fruit_2") or die(mysql_error());
$fruit_2 = mysql_result($fruit_2res, 0);
$fruit_2 = "$comma $fruit_2";
}
if ( $fruit_3 == '0' ) {
$fruit_3 = '';
} else { 
$fruit_3res = mysql_query("SELECT name FROM fruit WHERE id = $fruit_3") or die(mysql_error());
$fruit_3 = mysql_result($fruit_3res, 0);
$fruit_3 = "$comma $fruit_3";
}
if ( $fruit_4 == '0' ) {
$fruit_4 = '';
} else { 
$fruit_4res = mysql_query("SELECT name FROM fruit WHERE id = $fruit_4") or die(mysql_error());
$fruit_4 = mysql_result($fruit_4res, 0);
$fruit_4 = "$comma $fruit_4";
}


if ( $cheese_1 == '0' ) {
$cheese_1 = '';
} else { 
$cheese_1res = mysql_query("SELECT name FROM cheese WHERE id = $cheese_1") or die(mysql_error());
$cheese_1 = mysql_result($cheese_1res,
 0);
$cheese_1 = "$comma $cheese_1";
}
if ( $cheese_2 == '0' ) {
$cheese_2 = '';
} else { 
$cheese_2res = mysql_query("SELECT name FROM cheese WHERE id = $cheese_2") or die(mysql_error());
$cheese_2 = mysql_result($cheese_2res, 0);
$cheese_2 = "$comma $cheese_2";
}
if ( $cheese_3 == '0' ) {
$cheese_3 = '';
} else { 
$cheese_3res = mysql_query("SELECT name FROM cheese WHERE id = $cheese_3") or die(mysql_error());
$cheese_3 = mysql_result($cheese_3res, 0);
$cheese_3 = "$comma $cheese_3";
}
if ( $cheese_4 == '0' ) {
$cheese_4 = '';
} else { 
$cheese_4res = mysql_query("SELECT name FROM cheese WHERE id = $cheese_4") or die(mysql_error());
$cheese_4 = mysql_result($cheese_4res, 0);
$cheese_4 = "$comma $cheese_4";
}


$ingr = "$size$crust$meat_1$meat_2$meat_3$meat_4$fruit_1$fruit_2$fruit_3$fruit_4$cheese_1$cheese_2$cheese_3$cheese_4.";
mysql_query("UPDATE pizza SET ingr = '$ingr' WHERE id = '$pizza_id'") or die(mysql_error());
mysql_query("UPDATE pizza SET price = '$total' WHERE id = '$pizza_id'") or die(mysql_error());
echo "Klik <a href='bestellen_pizza.php'>hier</a> om deze pizza nu te bestellen.";



?>
			
				</div>
			</div>
			
			<div id="sidebar" class="left">
				<h3>Menu</h3>
				<div class="sidebar-nav">
					<ul>
					    <li><a href="index.php">Home</a></li>					   
					    <li><a href="menu.php">Menu</a></li>
					    <li><a href="mijnpizzas.php">Mijn Pizza's</a></li>
					    <li><a href="registreer.php">Registreren</a></li>
					</ul>
				</div>
				
				<a href="samenstellen.php" class="btn-buy"><em>Stel samen!</em></a>
			<div>
				<div class="advertisement">
					<h3>Bestseller</h3>
						<div class="ads">
							<p> Bekijk onze bestseller pizza en laat je verleiden! <br/> <br/> </p>
							<?php
								include 'bestseller.php';
							?>
							
						</div>
						<div class="cl">&nbsp;</div>
					</div>
				</div>
				
				
			</div>
			<div class="cl">&nbsp;</div>
		</div>
		
		<div class="shadow-l"></div>
		<div class="shadow-r"></div>
		<div class="shadow-b"></div>
	</div>
	
	<div id="footer">
		<div class="footer-nav left">
			<ul>
			    <li><a href="index.html">Home</a></li>
			    <li><a href="pizzario.html">Over PizzaRio</a></li>
			    <li><a href="menu.html">Menu</a></li>
			    <li><a href="bestsellers.html">Bestsellers</a></li>
			    <li><a href="inloggen.html">Inloggen</a></li>
			    <li class="last"><a href="contact.html">Contact</a></li>
			</ul>
		</div>
		<p class="copy right">Copyright &copy; PizzaRio ~ 2012 </p>
		<div class="cl">&nbsp;</div>
	</div>
</div>
</body>
</html>